Learn R Programming

chronosphere (version 0.3.1)

[,RasterArray,ANY,ANY-method: Indexing to extract subsets of a RasterArray object

Description

Single bracket '[' refers to indices and names within the RasterArray. Use double brackets to extract layers based on their names (in the stack).

Usage

# S4 method for RasterArray,ANY,ANY
[(x, i, j, ..., drop = TRUE)

Arguments

x

RasterArray object.

i

subscript of the first dimension(rows) or vector-like subsetting.

j

subscript of the second dimension (columns).

...

subscript of additional dimensions.

drop

logical in case the result of subsetting is a single element, should the RasterArray wrapper be dropped and the element be reduced to a single RasterLayer?

Value

A RasterLayer or RasterArray class object.

Examples

Run this code
# NOT RUN {
data(dems)
# numeric subsetting
firstThree <- dems[1:3]
# character subsetting
second <- dems["10"]
# logical subsetting
subscript <- rep(FALSE, length(dems))
subscript[2] <- TRUE
second2 <- dems[subscript]

# }

Run the code above in your browser using DataLab